|
1
|
|
|
var assert = require('assert'); |
|
2
|
|
|
const Board = require("../../src/chess/Board"); |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
describe('Check that board returns', function() { |
|
6
|
|
|
it("board == getBoard", function() { |
|
7
|
|
|
let board = new Board(); |
|
8
|
|
|
|
|
9
|
|
|
assert.equal(board.board, board.getBoard()); |
|
10
|
|
|
}); |
|
11
|
|
|
}); |
|
12
|
|
|
|
|
13
|
|
|
describe('check the value of an empty square', function() { |
|
14
|
|
|
it("Should return Square Co if empty", function() { |
|
15
|
|
|
let board = new Board(); |
|
16
|
|
|
|
|
17
|
|
|
assert.equal("F4", board.getSquare("F", 4)); |
|
18
|
|
|
}); |
|
19
|
|
|
}); |
|
20
|
|
|
|
|
21
|
|
|
describe('Check that square updated', function() { |
|
22
|
|
|
it("should change to 'T'", function() { |
|
23
|
|
|
let board = new Board(); |
|
24
|
|
|
board.updateSquare("F", 1, "T"); |
|
25
|
|
|
|
|
26
|
|
|
assert.equal("T", board.getSquare("F", 1)); |
|
27
|
|
|
}); |
|
28
|
|
|
}); |
|
29
|
|
|
|
|
30
|
|
|
describe('Check that piece moves as intended', function() { |
|
31
|
|
|
it("old x,y should be empty and nx, ny filled", function() { |
|
32
|
|
|
let board = new Board(); |
|
33
|
|
|
board.updateSquare("A", 1, "T"); |
|
34
|
|
|
assert.equal("T", board.getSquare("A", 1)); |
|
35
|
|
|
|
|
36
|
|
|
board.move("A", 1, "B", 2); |
|
37
|
|
|
assert.equal("T", board.getSquare("B", 2)); |
|
38
|
|
|
assert.equal("A1", board.getSquare("A", 1)); |
|
39
|
|
|
}); |
|
40
|
|
|
}); |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
describe('getAsciiBoard', function() { |
|
44
|
|
|
it("Should return string of lenght greater then 64", function() { |
|
45
|
|
|
let board = new Board(); |
|
46
|
|
|
let string = board.getAsciiBoard(); |
|
47
|
|
|
assert.ok(string.length > 64); |
|
48
|
|
|
}); |
|
49
|
|
|
}); |
|
50
|
|
|
|